export default function (url, data = {}, method = 'get') {
  return new Promise((resolve) => {
    wx.request({
      url: `https://www.codeman.ink/api${url}`,
      method,
      data,
      header: {
          cookie:wx.getStorageSync('cookie')
      },
      success: (res) => {
        if (data._isLogin) {
          const cookies =res.cookies
          wx.setStorageSync('cookie', cookies.find(item => {
            return item.startsWith('MUSIC_U')
          }))
        }
        resolve(res.data)
      }
    })
  })
}